package Test;
class MyCustomException extends Exception {
    private String errorMsg;

    public MyCustomException(String message) {
        this.errorMsg = message;
    }

    public void printError() {
        System.out.println("自定义异常信息：" + errorMsg);
    }
}

public class TestCustomException {
    public static void main(String[] args) {
        try {
            throw new MyCustomException("这是测试用的异常信息");
        } catch (MyCustomException e) {
            e.printError();
        }
    }
}